import "dart:io";

import "package:ct_pa_majordomo/app.dart";
import "package:ct_pa_majordomo/utils/storage.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_easyloading/flutter_easyloading.dart";
import "package:shared_preferences/shared_preferences.dart";

class GlobalHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  EasyLoading.instance.indicatorType = EasyLoadingIndicatorType.circle;
  EasyLoading.instance.maskType = EasyLoadingMaskType.clear;
  HttpOverrides.global = GlobalHttpOverrides();
  storage = await SharedPreferences.getInstance();
  if (Platform.isAndroid) {
    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        systemNavigationBarColor: Colors.transparent,
        statusBarColor: Colors.transparent,
      ),
    );
  }
  runApp(const App());
}
